﻿<!DOCTYPE HTML>
<html>
<head>
    <#include "common/_meta.html">
    <style>
        /*修改提示文字的颜色*/
        input::-webkit-input-placeholder { /* WebKit browsers */
            color: red;
        }
        input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            color: red;
        }
        input::-moz-placeholder { /* Mozilla Firefox 19+ */
            color: red;
        }
        input:-ms-input-placeholder { /* Internet Explorer 10+ */
            color: red;
        }
    </style>
<title>DRM-平台</title>
</head>
<body>
<input type="hidden" id="TenantId" name="TenantId" value="" />
<#--<div class="header"></div>-->
<div class="loginWraper">
	<div class="loginBox">
		<form action="/user/doLogin" id ="loginForm" class="form form-horizontal" method="post" onsubmit="return checkLoginForm()">
			<div class="row cl">
				<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
				<div class="formControls col-xs-8">
					<input name="name" id="name" type="text" placeholder="账户" class="input-text size-L">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
				<div class="formControls col-xs-8">
					<input name="pwd" id="pwd" type="password" placeholder="密码" class="input-text size-L">
				</div>
			</div>
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <input id="validateCode" name="validateCode" type="text" class="input-text size-L" placeholder="输入验证码" style="width:150px;"/>
                	<span class="y_yzimg"><img id="codeValidateImg" onClick="javascript:flushValidateCode();"/></span>
                	<a href="javascript:flushValidateCode();" >换一张</a>
                </div>
            </div>
			<div class="row cl">
				<div class="formControls col-xs-8 col-xs-offset-3">
					<input name="login" type="submit" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
					<input name="reset" type="reset" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
                    <input name="register" type="button" class="btn btn-default radius size-L" style="float:right" onclick="registerFun()" value="&nbsp;注&nbsp;&nbsp;&nbsp;&nbsp;册&nbsp;">
                </div>
			</div>
		</form>
	</div>
</div>
<div class="footer">北京首约科技有限公司</div>

<#include 'common/_footer.html'>

<script type="text/javascript" src="/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/resources/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/resources/lib/laypage/1.2/laypage.js"></script>


<!-- dom文档树加载完之后执行 -->
<script type="text/javascript">
    var codeIsOK = false;
    $(document).ready(function(){
		<#if status??>
            <#if status.code != 0>
                displayError("${status.msg}");
            </#if>
		</#if>

        flushValidateCode();//进入页面就刷新生成验证码
    });

	function registerFun() {
		var title = "用户注册";
		var url = "/user/registerUser";
		layer_show(title, url, 500, 410);
    }

    /* 登陆前校验 */
    function checkLoginForm() {
        var uName = document.getElementById("name").value;
        var password = pwd.value;
        if (uName === null || trim(uName) === ""
                || password === null || trim(password) === "") {
            displayError("用户名和密码不能为空");
            $("#userName").focus();
            return false;
        }
        var code = validateCode.value;
        checkCode(code);
        if (!codeIsOK) {
            $("#validateCode").val("")
            $("#validateCode").attr("placeholder", '验证码错误');
            flushValidateCode();
            return false;
        } else {
            return true;
        }
//        $("#loginForm").submit();
    }

    /* 校验验证码输入是否正确 */
    function checkCode(code){
        $.ajax({
            type: "get",
            url: "/checkimagecode",
            data: "validateCode=" + code,
            async: false,
            success: function (data) {
                if (data.code===0) {
                    codeIsOK = true;
                }
            }
        });
    }

    /* 刷新生成验证码 */
    function flushValidateCode(){
        var validateImgObject = document.getElementById("codeValidateImg");
        validateImgObject.src = "/getSysManageLoginCode?time=" + new Date();
    }

    /* 删除左右两端的空格 */
    function trim(str){
        return str.replace(/(^\s*)|(\s*$)/g, "");
    }

    /* 展示错误消息 */
    function displayError(message) {
        layer.msg(message, {icon:2,time:1000}, function () {layer_close();});
    }
</script>
</body>
</html>